apply plugin: 'com.github.johnrengelman.shadow'

description = "Testcontainers Core"

sourceSets {
    jarFileTest
}

test.maxParallelForks = 4

idea.module.testSourceDirs += sourceSets.jarFileTest.allSource.srcDirs

jar {
    manifest {
        attributes('Implementation-Version': project.getProperty("version"))
    }
}

shadowJar {
    [
        'META-INF/NOTICE',
        'META-INF/NOTICE.txt',
        'META-INF/LICENSE',
        'META-INF/LICENSE.txt',
        'META-INF/maven/',
        'META-INF/proguard/',
        'META-INF/versions/*/module-info.class',
        'META-INF/services/java.security.Provider',
    ].each { exclude(it) }
}

task jarFileTest(type: Test) {
    testClassesDirs = sourceSets.jarFileTest.output.classesDirs
    classpath = sourceSets.jarFileTest.runtimeClasspath

    file(shadowJar.outputs.files.singleFile) // input for correct caching
    systemProperty("jarFile", shadowJar.outputs.files.singleFile)

    dependsOn(shadowJar)
}
project.tasks.check.dependsOn(jarFileTest)

tasks.japicmp {
    packageExcludes = [
        "com.github.dockerjava.*",
        "org.testcontainers.shaded.*",
    ]

    classExcludes = [
        "org.testcontainers.utility.RyukResourceReaper",
    ]

    methodExcludes = [
        "org.testcontainers.containers.Container#getDockerClient()",
        "org.testcontainers.containers.ContainerState#getDockerClient()",
        "org.testcontainers.containers.ContainerState#execInContainer(org.testcontainers.containers.ExecConfig)",
        "org.testcontainers.containers.ContainerState#execInContainer(java.nio.charset.Charset,org.testcontainers.containers.ExecConfig)"
    ]

    fieldExcludes = []
}

configurations.all {
    resolutionStrategy {
        // use lower Jackson version
        force 'com.fasterxml.jackson.core:jackson-databind:2.8.8'
        force 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.8.8'
    }
}

dependencies {
    api 'junit:junit:4.13.2'
    api 'org.slf4j:slf4j-api:1.7.36'
    compileOnly 'org.jetbrains:annotations:24.1.0'
    testCompileOnly 'org.jetbrains:annotations:24.1.0'
    api 'org.apache.commons:commons-compress:1.24.0'
    api ('org.rnorth.duct-tape:duct-tape:1.0.8') {
        exclude(group: 'org.jetbrains', module: 'annotations')
    }

    provided('com.google.cloud.tools:jib-core:0.23.0') {
        exclude group: 'com.google.guava', module: 'guava'
        exclude group: 'com.fasterxml.jackson.datatype', module: 'jackson-datatype-jsr310'
        exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
        exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
        exclude group: 'org.apache.commons', module: 'commons-compress'
    }

    shaded 'org.awaitility:awaitility:4.2.1'

    api platform('com.github.docker-java:docker-java-bom:3.3.6')
    shaded platform('com.github.docker-java:docker-java-bom:3.3.6')

    api "com.github.docker-java:docker-java-api"

    shaded('com.github.docker-java:docker-java-core') {
        exclude group: 'com.google.guava', module: 'guava'
    }

    api 'com.github.docker-java:docker-java-transport-zerodep'

    shaded 'com.google.guava:guava:33.2.0-jre'
    shaded "org.yaml:snakeyaml:1.33"

    shaded 'org.glassfish.main.external:trilead-ssh2-repackaged:4.1.2'

    shaded 'org.zeroturnaround:zt-exec:1.12'

    testImplementation('com.google.cloud.tools:jib-core:0.23.0')  {
        exclude group: 'com.google.guava', module: 'guava'
    }
    testImplementation 'org.apache.httpcomponents:httpclient:4.5.14'
    testImplementation 'redis.clients:jedis:5.1.3'
    testImplementation 'com.rabbitmq:amqp-client:5.21.0'
    testImplementation 'org.mongodb:mongo-java-driver:3.12.14'

    testImplementation ('org.mockito:mockito-core:4.11.0') {
        exclude(module: 'hamcrest-core')
    }
    // Synthetic JAR used for MountableFileTest and DirectoryTarResourceTest
    testImplementation files('testlib/repo/fakejar/fakejar/0/fakejar-0.jar')

    testImplementation 'org.assertj:assertj-core:3.25.3'

    jarFileTestCompileOnly "org.projectlombok:lombok:${lombok.version}"
    jarFileTestAnnotationProcessor "org.projectlombok:lombok:${lombok.version}"
    jarFileTestImplementation 'junit:junit:4.13.2'
    jarFileTestImplementation 'org.assertj:assertj-core:3.25.3'
    jarFileTestImplementation 'org.ow2.asm:asm-debug-all:5.2'
}

tasks.generatePomFileForMavenJavaPublication.finalizedBy(
    tasks.register('checkPOMdependencies', org.testcontainers.build.ComparePOMWithLatestReleasedTask) {
        ignore = [
        ]
    }
)
